/**============================================================================
 Confidential Information - Limited distribution to authorized persons only.
 This software is protected as an unpublished work under the U.S. Copyright
 Act of 1976.

 Copyright (c) 2012, BluePhoenix Solutions, Inc. All rights reserved.
 ----------------------------------------------------------------------------
 file......: Alarm.java
 Author....: Vyacheslav Kovalyov
 Created...: 2/15/12

 Description:

 ============================================================================*/
package ru.monyag.android.vibralarm.alarm;

import ru.monyag.android.vibralarm.exceptions.TimeFormatException;

import static ru.monyag.android.vibralarm.utils.Constants.MAX_HOURS;
import static ru.monyag.android.vibralarm.utils.Constants.MAX_MINUTES;

/**
 * @author Vyacheslav Kovalyov
 * @version 1.0
 */
public class Alarm {

    public Alarm() {
        this(0, 0);
    }

    public Alarm(int hh, int mm) {

        try {
            setHours(hh);
            setMinutes(mm);
        } catch (TimeFormatException e) {
            reset();
        }
    }

    public void reset() {
        this.minutes = 0;
        this.hours = 0;
    }

    public int getHours() {
        return hours;
    }

    public void setHours(int hours) throws TimeFormatException {
        if (hours > MAX_HOURS) {
            throw new TimeFormatException();
        }

        this.hours = hours;
    }

    public int getMinutes() {
        return minutes;
    }

    public void setMinutes(int minutes) throws TimeFormatException {
        if (minutes > MAX_MINUTES) {
            throw new TimeFormatException();
        }

        this.minutes = minutes;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }
    
    /*
    CREATE TABLE [alarms] (
  [ID] INTEGER NOT NULL UNIQUE PRIMARY KEY ON CONFLICT ROLLBACK AUTOINCREMENT, 
  [NAME] CHAR(255), 
  [HH] INT NOT NULL ON CONFLICT ROLLBACK DEFAULT (0), 
  [MM] INT NOT NULL ON CONFLICT ROLLBACK DEFAULT (0), 
  [DAY_CODE] INT DEFAULT (0), 
  [ALARM_ENABLED] BOOLEAN DEFAULT (0));
    * */

    private int id;
    private String name;
    private int hours;
    private int minutes;
    private boolean enabled;
}